
//
//  DetailMessageViewController.m
//  NiuBanGold
//
//  Created by zf on 15/12/8.
//  Copyright © 2015年 zzjr. All rights reserved.
//

#import "DetailMessageViewController.h"

@interface DetailMessageViewController ()

@end

@implementation DetailMessageViewController
//-(void)loadView {
//    UIScrollView *view = [[UIScrollView alloc]initWithFrame:self.view.frame];
//    self.view = view;
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"消息详情";
    self.view.backgroundColor = BASECOLOR;
    
    [self addSubViews];
    
}

-(void)addSubViews {
   
    UIView *view_background = [[UIView alloc]initWithFrame:CGRectMake(MULTIPLYWIDTH(30.0 / 2), MULTIPLYHEIGHT(29.0 / 2), SCREEN_WIDTH - MULTIPLYWIDTH(30.0), MULTIPLYHEIGHT(10))];
    view_background.backgroundColor = [UIColor whiteColor];
    view_background.layer.borderWidth = 1;
    view_background.layer.borderColor = [UsefulUtil colorWithHexString:@"#d3d3d3"].CGColor;
    view_background.layer.masksToBounds = YES;
    view_background.layer.cornerRadius = 8;
    [self.view addSubview:view_background];
    //title
    UILabel *label_title = [[UILabel alloc]initWithFrame:CGRectMake(MULTIPLYWIDTH(20.0 / 2), MULTIPLYHEIGHT(16.0 / 2), MULTIPLYWIDTH(200.0 / 2), MULTIPLYHEIGHT(26.0 / 2))];
    label_title.text = self.message.message_title;
    label_title.font = [UIFont systemFontOfSize:13.0];
    label_title.textColor = [UsefulUtil colorWithHexString:@"#434343"];
    [view_background addSubview:label_title];
    
    //time
    UILabel * label_time = [[UILabel alloc]initWithFrame:CGRectMake(MULTIPLYWIDTH(440.0 / 2), MULTIPLYHEIGHT(16.0 / 2), MULTIPLYWIDTH(220.0 / 2), MULTIPLYHEIGHT(26.0 / 2))];
    label_time.text = self.message.message_date;
    label_time.textColor = [UsefulUtil colorWithHexString:@"#989898"];
    label_time.font = [UIFont systemFontOfSize:12.0];
    label_time.adjustsFontSizeToFitWidth = YES;
    [view_background addSubview:label_time];
    
    //消息内容
    UITextView *label_message = [[UITextView alloc]initWithFrame:CGRectMake(MULTIPLYWIDTH(MULTIPLYWIDTH(20.0 / 2)), CGRectGetMaxY(label_title.frame) + MULTIPLYHEIGHT(32.0 / 2),view_background.frame.size.width - MULTIPLYWIDTH(30.0), MULTIPLYHEIGHT(40))];
    [view_background addSubview:label_message];
    label_message.text = self.message.message_contnet;

    label_message.editable = NO;
    label_message.font = [UIFont systemFontOfSize:12.0];
     label_message.textColor = [UsefulUtil colorWithHexString:@"#434343"];
    //计算内容高度
    CGSize size_message = [label_message sizeThatFits:CGSizeMake(view_background.frame.size.width, 9999)];
    
    
    if (size_message.height > SCREEN_HEIGHT) {
        
        size_message = CGSizeMake(view_background.frame.size.width, SCREEN_HEIGHT - 64-30-44);
    }else {
        label_message.scrollEnabled = NO;
        [label_message setFrame:  CGRectMake(MULTIPLYWIDTH(MULTIPLYWIDTH(20.0 / 2)), CGRectGetMaxY(label_title.frame) + MULTIPLYHEIGHT(32.0 / 2),view_background.frame.size.width - MULTIPLYWIDTH(30.0 / 2), size_message.height)];
    }
    
    [view_background setFrame:CGRectMake(MULTIPLYWIDTH(30.0 / 2), MULTIPLYHEIGHT(29.0 / 2), SCREEN_WIDTH - MULTIPLYWIDTH(30.0), CGRectGetHeight(label_message.frame) + CGRectGetHeight(label_title.frame) + MULTIPLYHEIGHT(16.0 / 2  + 32.0 / 2 + 36.0 / 2))];
    
    

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
